<template>
	<view>
		<view style="background-color: #fff;position: relative;padding-left: 150upx;height: 200upx;margin: 20upx;border-radius: 20upx;">
			<view style="position: absolute;top: 60upx;left: 30upx;">
				<image style="width: 80upx;height: 80upx;" src="../../../static/Adress.png" mode=""></image>
			</view>
			<view style="display: flex;">
				<view style="line-height: 150upx;">
					{{name}}
				</view>
				<view style="line-height: 150upx;margin-left: 30upx;">
					{{mobile}}
				</view>
			</view>
			<view style="margin-top: -40upx;">
				{{province_name}}{{city_name}}{{district_name}}{{address}}
			</view>
		</view>
		<view style="background-color: #fff;position: relative;height: 600upx;margin: 20upx;border-radius: 20upx;padding: 30upx;">
			<view v-if="id != 0" v-for="(item,index) in orderGoods" :key="index" style="display: flex;justify-content: space-around;height: 170upx;border-bottom: 1upx solid #E5E5E5;">
				<view >
					<image style="width: 150upx;height: 150upx;" :src="item.goods_thumb_image" mode=""></image>
				</view>
				<view>
					<view style="line-height: 100upx;">
						{{item.goods_name}}
					</view>
					<view style="margin-top: -20upx;color: #7F7F7F;">
						{{item.format}}
					</view>
				</view>
				<view style="line-height: 150upx;">
					X{{item.number}}
				</view>
				<view>
					<view style="line-height: 100upx;">
						¥{{item.turnover_price}}
					</view>
					<view style="margin-top: -20upx;color: #7F7F7F;">
						¥{{item.cost_price}}
					</view>
				</view>
			</view>
			<view v-if="group_id != 0" style="display: flex;justify-content: space-around;height: 170upx;border-bottom: 1upx solid #E5E5E5;">
				<view >
					<image style="width: 150upx;height: 150upx;" :src="goods_thumb_image" mode=""></image>
				</view>
				<view>
					<view style="line-height: 100upx;">
						{{goods_name}}
					</view>
					<view style="margin-top: -20upx;color: #7F7F7F;">
						{{format}}
					</view>
				</view>
				<view style="line-height: 150upx;">
					X{{number}}
				</view>
				<view>
					<view style="line-height: 100upx;">
						¥{{pay_price}}
					</view>
					<!-- <view style="margin-top: -20upx;color: #7F7F7F;">
						¥{{cost_price}}
					</view> -->
				</view>
			</view>
			
			<view v-if="limitTime_id != 0" style="display: flex;justify-content: space-around;height: 170upx;border-bottom: 1upx solid #E5E5E5;">
				<view >
					<image style="width: 150upx;height: 150upx;" :src="goods_thumb_image" mode=""></image>
				</view>
				<view>
					<view style="line-height: 100upx;">
						{{goods_name}}
					</view>
					<view style="margin-top: -20upx;color: #7F7F7F;">
						{{format}}
					</view>
				</view>
				<view style="line-height: 150upx;">
					X{{number}}
				</view>
				<view>
					<view style="line-height: 100upx;">
						¥{{pay_price}}
					</view>
					<view style="margin-top: -20upx;color: #7F7F7F;">
						¥{{cost_price}}
					</view>
				</view>
			</view>
			
			<view style="display: flex;justify-content: space-between;height: 70upx;line-height: 70upx;margin-top: 30upx;">
				<view >
					产品金额
				</view>
				<view >
					¥{{pay_price}}
				</view>
			</view>
			<view style="display: flex;justify-content: space-between;height: 70upx;line-height: 70upx;">
				<view >
					优惠券
				</view>
				<view>
					-¥{{tax_id}}
				</view>
			</view><view style="display: flex;justify-content: space-between;height: 70upx;line-height: 70upx;">
				<view >
					运费
				</view>
				<view >
					¥0
				</view>
			</view>
			<view style="display: flex;justify-content: space-between;height: 70upx;line-height: 70upx;">
				<view >
					支付方式
				</view>
				<view >
					自购
				</view>
			</view>
			<view style="display: flex;justify-content: space-between;height: 70upx;line-height: 70upx;">
				<view >
					总计
				</view>
				<view >
					¥{{pay_price}}
				</view>
			</view>
		</view>
			<view style="background-color: #fff;position: relative;height: 100upx;margin: 20upx;border-radius: 20upx;padding: 30upx;">
				<view style="display: flex;justify-content: space-between;height: 70upx;line-height: 70upx;">
					<view >
						发票信息
					</view>
					<view  style="color: #7F7F7F;">
						>
					</view>
				</view>
				</view>
	</view>
</template>
<script>
	export default{
		data(){
			return{
				id:0,
				group_id:'',
				user_id:'',
				order_id:'',
				name:'',
				mobile:'',
				province_name:'',
				city_name :'',
				district_name :'',
				address :'',
				orderGoods:'',
				pay_price:'',
				tax_id:'',
				limitTime_id:0,
				}
			},
			onLoad(e) {
				uni.getStorage({
					key: 'user_id',
					success: (res) => {
						this.user_id = res.data
					}
				});
				if(e.id){
					this.order_id = e.id
					this.id = e.id
					this.getdata()
				}
				if(e.group_id){
					this.order_id = e.group_id
					this.group_id = e.group_id
					this.getdata1()
				}
				if(e.limitTime_id){
					this.order_id = e.limitTime_id
					this.limitTime_id = e.limitTime_id
					this.getdata2()
				}
				
			},
			methods:{
				getdata(){
					// 普通订单详情
					uni.request({
						url:'https://cx.mingmeijt.com/Api/Order/orderDetail',
						method:'POST',
						data:{
							user_id:this.user_id,
							order_id:this.order_id,
						},
						header:{'Content-Type':'application/x-www-form-urlencoded'},
						success: (res) => {
							console.log(res)
							this.name = res.data.data.addressInfo.name
							this.mobile = res.data.data.addressInfo.mobile
							this.province_name = res.data.data.addressInfo.province_name
							this.city_name = res.data.data.addressInfo.city_name
							this.district_name = res.data.data.addressInfo.district_name
							this.address = res.data.data.addressInfo.address
							this.orderGoods = res.data.data.orderGoods
							this.pay_price = res.data.data.orderInfo.pay_price
							this.tax_id = res.data.data.orderInfo.tax_id
							// console.log(this.name)
							for(var i = 0; i<this.orderGoods.length; i++) {
									this.orderGoods[i].goods_thumb_image = 'https://cx.mingmeijt.com' + this.orderGoods[i].goods_thumb_image
									// console.log(this.orderGoods[i].goods_thumb_image)
								}
							
						}
					})
				},
				getdata1(){
					// 拼团订单详情
					uni.request({
						url:'https://cx.mingmeijt.com/Api/AssembleOrder/orderDetail',
						method:'POST',
						data:{
							user_id: this.user_id,
							order_id: this.order_id,
						},
						header:{'Content-Type':'application/x-www-form-urlencoded'},
						success: (res) => {
							console.log(res)
							this.name = res.data.data.addressInfo.name
							this.mobile = res.data.data.addressInfo.mobile
							this.province_name = res.data.data.addressInfo.province_name
							this.city_name = res.data.data.addressInfo.city_name
							this.district_name = res.data.data.addressInfo.district_name
							this.address = res.data.data.addressInfo.address
							
							this.pay_price = res.data.data.orderInfo.pay_price
							this.tax_id = res.data.data.orderInfo.tax_id
							this.goods_thumb_image = 'https://cx.mingmeijt.com' + res.data.data.orderInfo.goods_thumb
							this.format = res.data.data.orderInfo.format
							this.goods_name = res.data.data.orderInfo.goods_name
							this.number = res.data.data.orderInfo.number
							this.pay_price = res.data.data.orderInfo.pay_price
							// this.cost_price = res.data.data.orderInfo.cost_price
									
						}
					})
				},
				getdata2(){
					// 抢购订单详情
					uni.request({
						url:'https://cx.mingmeijt.com/Api/PanicBuyingOrder/orderDetail',
						method:'POST',
						data:{
							user_id:this.user_id,
							order_id:this.order_id,
						},
						header:{'Content-Type':'application/x-www-form-urlencoded'},
						success: (res) => {
							console.log(res)
							this.name = res.data.data.addressInfo.name
							this.mobile = res.data.data.addressInfo.mobile
							this.province_name = res.data.data.addressInfo.province_name
							this.city_name = res.data.data.addressInfo.city_name
							this.district_name = res.data.data.addressInfo.district_name
							this.address = res.data.data.addressInfo.address
							
							this.pay_price = res.data.data.orderInfo.pay_price
							this.tax_id = res.data.data.orderInfo.tax_id
							this.goods_thumb_image = 'https://cx.mingmeijt.com' + res.data.data.orderInfo.goods_thumb_image
							this.format = res.data.data.orderInfo.format
							this.goods_name = res.data.data.orderInfo.goods_name
							this.number = res.data.data.orderInfo.number
							this.pay_price = res.data.data.orderInfo.pay_price
							this.cost_price = res.data.data.orderInfo.cost_price
									
							console.log(this.goods_thumb_image)	
							
						}
					})
				},
			}
	}
</script>